package com.zhou.javablog.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.hexun.framework.core.controller.DefaultBaseController;
import com.zhou.javablog.entity.ContentType;
import com.zhou.javablog.service.ContentTypeService;
/**
 * 文章类型对应表
 * @author zhoudong
 *
 */
@Controller
@RequestMapping("content/type")
public class ContentTypeController extends DefaultBaseController{
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Resource
	private ContentTypeService contentTypeService;
	
	/**
	 * 查询出所有的类型和对应关系
	 * @return
	 */
	@RequestMapping(value="findAll",method={RequestMethod.GET,RequestMethod.POST})
	public @ResponseBody Map<String, Object> findAll() {
		List<ContentType> list = contentTypeService.findAll();
		logger.info("查询出文章类型对应关系：{}", JSON.toJSON(list).toString());
		resultMap.put("types", list);
		return resultMap;
	}
}
